package adebo.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class DAOProperties {
	// Constants ----------------------------------------------------------------------------------

    private static final String PROPERTIES_FILE = "dao.properties";
    private static final Properties PROPERTIES = new Properties();
    private final String specificKey;

    static {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        InputStream propertiesFile = classLoader.getResourceAsStream(PROPERTIES_FILE);
//        URL url = ClassLoader.getSystemResource(PROPERTIES_FILE);
        try {
//        	PROPERTIES.load(url.openStream());
			PROPERTIES.load(propertiesFile);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
       
    }

    public DAOProperties(String specificKey){
        this.specificKey = specificKey;
    }


  
    public String getProperty(String pKey) {
        String fullKey = specificKey + "." + pKey;
        String property = PROPERTIES.getProperty(fullKey);

        return property;
    }


}
